<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2021/11/25
  Time: 14:32
  To change this template use File | Settings | File Templates.
--%>

<%@ page import="java.util.List" %>
<%@ page import="com.yyyzzz.bean.Course" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.yyyzzz.service.courseService" %>
<%@ page import="com.yyyzzz.service.impl.courseServiceimpl" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" language="java" %>
<style>
    .odd {
        background-color: #999e98;
    }

    .even {
        background-color: #4f5152;
    }
</style>
<html>
<head>
    <title>课程信息</title>
    <link rel="stylesheet" href="courseDetail/courseDetail.css" type="text/css">

</head>

<div>
</div>
<body>
<center>
    <header>
        <a href="#" class="logo">学生选课系统</a>
        <ul>
            <li>
                <a href="#" class="active">可选课程</a>

            </li>
            <li><a  href="addCourse.jsp">增加课程</a>
            </li>
            <li><a href="updateCourse.jsp">修改课程</a>
            </li>
            <li><a href="#">查看个人信息</a></li>
        </ul>
    </header>
    <section>
        <img src="Login/stars.png" id="stars">
        <img src="Login/moon.png" id="moon">
        <img src="Login/mountainsbehind.png" id="mountains_behind">
        <h2>下拉查看全部课程</h2>
        <div class="mes">${error}</div>
        <form action="selectOneServlet" method="post">
            <a href="#" id="btn" class="btn">
                <input type="text" name="courseId" id="search" onfocus="bc()" onblur="lk()" placeholder="请输入课程号"><input
                    type="submit" value="查询" class="sub">
            </a>
        </form>
        <img src="Login/mountainsfront.png" id="mountains_front">
    </section>
    <script>
        let stars = document.getElementById('stars');
        let moom = document.getElementById('moon');
        let mountains_behind = document.getElementById('mountains_behind');
        let mountains_front = document.getElementById('mountains_front');
        let text = document.getElementById('text');
        let btn = document.getElementById('btn');
        let header = document.querySelector('header');
        window.addEventListener('scroll', function () {
            let value = window.scrollY;
            stars.style.left = value * 0.25 + 'px';
            moom.style.top = value * 1.05 + 'px';
            mountains_behind.style.top = value * 0.5 + 'px';
            mountains_front.style.top = value * 0 + 'px';
            text.style.marginRight = value * 4 + 'px';
            text.style.marginTop = value * 1.5 + 'px';
            btn.style.marginRight = value * 4 + 'px';
            header.style.top = value * 0.5 + 'px';

        })

        function bc() {
            document.getElementById("search").style.width = '600px';
        }

        function lk() {
            document.getElementById("search").style.width = '200px';
        }
    </script>
    <div id="sec" class="sec">
        <div>
            <table cellspacing="0" class="tab">
                <caption>课程信息</caption>

                <tr>
                    <td align="center">
                        课程号
                    </td>
                    <td align="center">
                        课程名
                    </td>

                    <td align="center">
                        任课教师
                    </td>
                    <td align="center">
                        教室
                    </td>
                    <td align="center">
                        学分
                    </td>
                    <td align="center" colspan="2" id="">
                        操作
                    </td>

                </tr>
                <%
                    courseService service = new courseServiceimpl();
                    List<Course> courseList = service.getAll();
                    request.setAttribute("courseList", courseList);
                    Object obj = request.getAttribute("courseList");
                  /*  if (obj != null) {
                        List<Course> courseList1 = (List) obj;
                        for (Course course : courseList1) {*/
                %>
                <c:forEach items="${courseList}" var="course" varStatus="vs">

                    <tr class="${vs.count%2==0?'even':'odd'}">
                        <td align="center">
                                ${course.courseId}
                                <%-- <%=course.getCourseId()%>--%>
                        </td>
                        <td align="center">
                                ${course.courseName}
                                <%--  <%=course.getCourseName()%>--%>
                        </td>
                        <td align="center">
                                ${course.courseTeacher}
                                <%--<%=course.getCourseTeacher()%>--%>
                        </td>
                        <td align="center">
                                ${course.classroom}
                                <%--<%=course.getClassroom()%>--%>
                        </td>
                        <td align="center">
                                ${course.credit}
                                <%--<%=course.getCredit()%>--%>
                        </td>
                        <td align="center" id="cao1">
                            <a style="color: #ffffff;"
                               href="updateFindOneServlet?courseid=${course.courseId}<%--<%=course.getCourseId()%>--%>">修改</a>
                        </td>
                        <td id="cao1" align="center">
                            <a style="color: #ff0000;"
                               href="delectCourseServlet?courseid=${course.courseId}<%--<%=course.getCourseId()%>--%>"
                               onClick="if(!confirm('您确定删除该课程吗？'))
    return false;else return true;">删除</a>
                        </td>
                            <%-- <%
                                     }
                                 }
                             %>--%>
                    </tr>

                </c:forEach>


            </table>
        </div>
        <a href="addCourse.jsp" class="cao2">增加课程</a>
        <a href="updateCourse.jsp" class="cao2">修改</a>
    </div>

</center>
</body>
</html>